class Solution(object):
    def findMinMoves(self, machines):
        """
        :type machines: List[int]
        :rtype: int
        """
        n = len(machines)
        t = sum(machines)
        if t % n != 0:
            return -1
        target = t // n
        s = 0
        ans = 0
        for num in machines:
            num = num - target
            s += num
            ans = max(ans, abs(s), num)
        return ans


data = Solution()
machines = [1, 0, 5]
print(data.findMinMoves(machines))
